﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data.Common;
using Keel.ORM;
using System.Data;
using System.Data.SqlClient;

namespace Keel.DB
{
    public class SQLServer  :IDatabase 

    {
        public SQLServer(string connectstring)
        {
            ConnectString = connectstring;
        }
        public DbProviderFactory GetProviderFactory()
        {
            return System.Data.SqlClient.SqlClientFactory.Instance;  
        }
        public string ConnectString { get; set; }

        public Type PasteType(string dbtypestring)
        {
            Type t = null;
            SqlDbType sd = GetSQLDBTypeByString(dbtypestring);
            t = MetaType.GetMetaTypeFromSqlDbType(sd, false).ClassType ;
            return t;
        }

        public  static SqlDbType GetSQLDBTypeByString(string dbtypestring)
        {
            SqlDbType sd = (SqlDbType)Enum.Parse(typeof(SqlDbType), dbtypestring, true);
            return sd;
        }

        public DbType  PasteDBType(string dbtypestring)
        {
            DbType t;
            SqlDbType sd = GetSQLDBTypeByString(dbtypestring);
            t = MetaType.GetMetaTypeFromSqlDbType(sd, false).DbType ;
            return t;
        }

   
     
 
    }
}
